import {
    getGoodDetail,
    addCartGood
} from '../../config/api.js';
import {
    WXShowToast,
    WXNavigateTo
} from '../../utils/index.js'
var appInst = getApp();

Page({
    data: {
        host: appInst.globalData.host,
        goodid: undefined,
        good: {}
    },
    onLoad: function (options) {
        this.setData({
            goodid: options.goodid
        })
        this._getGoodDetail(options.goodid)
    },
    _getGoodDetail(goodid) {
        getGoodDetail(goodid).then(res => {
            this.setData({
                good: res
            })
        }).catch(err => {
            console.log(err)
        })
    },

  
    _addCart() {
        WXNavigateTo(`/pages/select_addr/select_addr?goodid=${this.data.goodid}&price=${this.data.good.price}`)
    }
})
